<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Tailieus extends CI_Model {
	function __construct()
	{
		parent::__construct();
		$this->load->helper("url");
		$this->load->database();
	}
	public function getTypeTailieu($type){
		$this->db->where('id_type_tailieu_vtv4',$type);
		$query = $this->db->get("vtv4_type_tailieu");
		return $query->row();
	}
	public function them_danhsach_tailieu($data){
		return $this->db->insert('vtv4_type_tailieu',$data);
	}
	public function sua_danhsach_tailieu($data,$id_type_tailieu){
		$this->db->where('id_type_tailieu_vtv4',$id_type_tailieu);
		return $this->db->update('vtv4_type_tailieu',$data);
	}
	public function del_danhsach_tailieu(){
		$this->db->where('id_type_tailieu_vtv4');
		return $this->db->delete('vtv4_type_tailieu');
	}
	public function listTailieu(){
		$query = $this->db->get('vtv4_type_tailieu');
		return $query->result();
	}	
	public function getAllTailieu($type)
	{
		$this->db->where('loai_tailieu',$type);
		$query = $this->db->get('vtv4_tailieu');
		return $query->result();
	}
	public function insertTailieu($data)
	{
		return $this->db->insert('vtv4_tailieu',$data);
	}
	public function getTailieu($id_tailieu)
	{
		$this->db->where('id_tailieu',$id_tailieu);
		$query = $this->db->get('vtv4_tailieu');
		return $query->row();
	}
	public function editTailieu($id_tailieu,$data)
	{
		$this->db->where('id_tailieu',$id_tailieu);
		return $this->db->update('vtv4_tailieu',$data);		
	}
	public function delTailieu($id_tailieu)
	{
		$this->db->where('id_tailieu',$id_tailieu);
		return $this->db->delete('vtv4_tailieu');		
	}
}